import java.io.File;

public class XMLFileFinder {

    public static void main(String[] args) {
        File folder = new File("/Users/lbh/devTools/Dleep Learning/data/VOCdevkit/VOC2007/Annotations");
        String targetName = "person";

        String result = findXMLFileByName(folder, targetName);

        if (result != null) {
            System.out.println("Found file: " + result);
        } else {
            System.out.println("No such file found!");
        }
    }

    public static String findXMLFileByName(File folder, String targetName) {
        if (folder == null || !folder.isDirectory()) {
            return null;
        }

        for (File file : folder.listFiles()) {
            if (file.isDirectory()) {
                String result = findXMLFileByName(file, targetName);
                if (result != null) {
                    return result;
                }
            } else if (file.getName().endsWith(".xml")) {
                String xmlContent = readFileContent(file);
                if (xmlContent.contains("<name>" + targetName + "</name>")) {
                    return file.getName();
                }
            }
        }

        return null;
    }

    private static String readFileContent(File file) {
        // Read the content of the file and return as string
        return null;
    }
}
